﻿Namespace Darkorbit.[Const]
    Public Class Server
        Public Const GLOBAL_EUROPE_1 As String = "int1"
        Public Const GLOBAL_EUROPE_2 As String = "int5"
        Public Const GLOBAL_EUROPE_3 As String = "int7"
        Public Const GLOBAL_EUROPE_4 As String = "int10"
        Public Const GLOBAL_EUROPE_5 As String = "int11"
        Public Const GLOBAL_EUROPE_6 As String = "int13"
        Public Const GLOBAL_EUROPE_7 As String = "int14"
        Public Const GLOBAL_AMERICA_1 As String = "int2"
        Public Const GLOBAL_AMERICA_2 As String = "int6"
        Public Const GLOBAL_AMERICA_3 As String = "int12"
        Public Const GLOBAL_AMERICA_4 As String = "int8"
        Public Const GLOBAL_AMERICA_5 As String = "int15"
        Public Const GERMANY_1 As String = "de1"
        Public Const GERMANY_2 As String = "de2"
        Public Const GERMANY_3 As String = "de3"
        Public Const GERMANY_4 As String = "de4"
        Public Const GERMANY_5 As String = "de5"
        Public Const GERMANY_6 As String = "de6"
        Public Const GERMANY_7 As String = "de7"
        Public Const SKANDINAVIA_1 As String = "int3"
        Public Const SKANDINAVIA_2 As String = "int4"
        Public Const BRAZIL_1 As String = "br1"
        Public Const BRAZIL_2 As String = "br2"
        Public Const HUNGARY_1 As String = "hu1"
        Public Const TURKEY_1 As String = "tr1"
        Public Const TURKEY_2 As String = "tr2"
        Public Const TURKEY_3 As String = "tr3"
        Public Const TURKEY_4 As String = "tr4"
        Public Const TURKEY_5 As String = "tr5"
        Public Const TURKEY_6 As String = "tr6"
        Public Const RUSSIA_1 As String = "ru1"
        Public Const RUSSIA_2 As String = "ru2"
        Public Const RUSSIA_3 As String = "ru3"
        Public Const RUSSIA_4 As String = "ru4"
        Public Const RUSSIA_5 As String = "ru5"
        Public Const RUSSIA_6 As String = "ru6"
        Public Const GREAT_BRITAIN_1 As String = "gb1"
        Public Const GREAT_BRITAIN_2 As String = "gb2"
        Public Const USA_EAST_1 As String = "us1"
        Public Const USA_WEST_1 As String = "us2"
        Public Const USA_EAST_2 As String = "us3"
        Public Const USA_EAST_3 As String = "us4"
        Public Const POLAND_1 As String = "pl1"
        Public Const POLAND_2 As String = "pl2"
        Public Const POLAND_3 As String = "pl3"
        Public Const FRANCE_1 As String = "fr1"
        Public Const FRANCE_2 As String = "fr2"
        Public Const FRANCE_3 As String = "fr3"
        Public Const FRANCE_4 As String = "fr4"
        Public Const ITALY_1 As String = "it1"
        Public Const ITALY_2 As String = "it2"
        Public Const ITALY_3 As String = "it3"
        Public Const SPAIN_1 As String = "es1"
        Public Const SPAIN_2 As String = "es2"
        Public Const SPAIN_3 As String = "es3"
        Public Const SPAIN_4 As String = "es4"
        Public Const MEXICO_1 As String = "mx1"
        Public Const CZECH_REPUBLIC_1 As String = "cz1"
        Public Const CZECH_REPUBLIC_2 As String = "cz2"
        Public Const CZECH_REPUBLIC_3 As String = "cz3"


        Public Shared Function BuildServerClass(ByVal input As String) As String
            Dim l As New List(Of String())
            '   Dim str As String = IO.File.ReadAllText("C:\Users\Alex\Desktop\xx.txt")
            Dim str As String = IO.File.ReadAllText(input)
            Dim b As Boolean = True
            For i As Integer = 0 To str.Split("<"c).Count - 1 Step 1
                Dim s As String() = str.Split("<"c)
                If s(i).StartsWith("td>") Then
                    If b Then
                        l.Add(New String() {s(i).Replace("td>", ""), s(i + 2).Replace("td>", "")})
                        b = False
                    Else
                        b = True
                    End If

                End If

            Next
            Dim sb As New System.Text.StringBuilder

            sb.AppendLine("Public Class Server")
            For Each item In l
                If item(0).Trim <> "" Then
                    sb.AppendLine("Public Const " & Strings.Left(item(0).Replace(" ", "_").ToUpper, Len(item(0).Replace(" ", "_").ToUpper) - 1) & " As String = " & Chr(34) & item(1).Trim() & Chr(34))
                End If
            Next
            sb.AppendLine("End Class")

            Return sb.ToString
        End Function
    End Class
End Namespace
